home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
et
/
et3_0-a1.lha
/
et3
/
src
/
Dialog.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-24
|
3KB
|
178 lines
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialog.h"
#include "Class.h"
#include "Error.h"
#include "CmdNo.h"
#include "Window.h"
#include "Buttons.h"
//---- Dialog ------------------------------------------------------------------
NewMetaImpl(Dialog,Manager, (T(actionId)));
Dialog::Dialog(char *name, WindowFlags f) : Manager(name, eMgrHide, eWinDialog)
{
wflags= f;
actionId= cIdNone;
}
Point Dialog::GetInitialWindowSize()
{
return cAutoSize;
}
VObject *Dialog::DoMakeContent()
{
fprintf(stderr, "Dialog::DoCreateDialog: You should better override DoMakeContent()\n");
return DoCreateDialog();
}
MenuBar *Dialog::DoMakeMenuBar()
{
return 0;
}
void Dialog::EnableItem(int id, bool b)
{
VObject *vop;
if (vop= FindItem(id))
vop->Enable(b, TRUE);
}
VObject *Dialog::FindItem(int id)
{
Window *bw= GetWindow();
if (bw) {
VObject *vop= bw->GetViewedVObject();
if (vop)
return vop->FindItem(id);
}
return 0;
}
void Dialog::DoSetDefaults()
{
}
void Dialog::DoSave()
{
}
void Dialog::DoRestore()
{
}
void Dialog::DoStore()
{
}
void Dialog::DoSetup()
{
}
int Dialog::ShowAt(VObject *fp, Point p)
{
MakeWindows();
DoSetDefaults();
DoSave();
DoSetup();
OpenAt(fp, p, TRUE);
return actionId;
}
int Dialog::ShowUnderMouse()
{
if (gWindow)
return ShowAt(gWindow, gToken.Pos);
return 0;
}
int Dialog::ShowOnWindow(VObject *fp)
{
if (fp)
return ShowAt(fp, fp->GetExtent().Half());
return ShowUnderMouse();
}
Point Dialog::GetInitialPos(Point e)
{
VObject *dfltButton= GetDefaultButton();
if (dfltButton)
return dfltButton->GetPortPoint(dfltButton->contentRect.Center());
return e.Half();
}
void Dialog::Cancel()
{
actionId= cIdCancel;
Dismiss();
DoRestore();
}
bool Dialog::AboutToDismiss()
{
if (GetFirstHandler()) {
bool rc= GetFirstHandler()->KbdFocus(FALSE);
if (!rc)
return FALSE;
GetFirstHandler()->KbdFocus(TRUE);
}
return TRUE;
}
void Dialog::Control(int id, int part, void *vp)
{
if (id != cIdNone && part == cPartAction) {
actionId= id;
switch (id) {
case cIdDefault:
DoSetDefaults();
break;
case cIdYes:
case cIdOk:
if (Dismiss()) {
DoStore();
return;
}
break;
case cCLOSE:
case cIdCancel:
actionId= cIdCancel;
Cancel();
return;
case cIdNo:
if (Close())
return;
break;
case cHELP:
break;
default:
if (Dismiss()) {
DoStore();
return;
}
break;
}
}
Manager::Control(id, part, vp);
DoSetup();
}
//---- obsolete ----------------------------------------------------------------
VObject *Dialog::DoCreateDialog()
{
AbstractMethod("DoMakeContent");
return 0;
}